from django.db import models
from app.server_status.models import McServerStatus


class McService(models.Model):
    name = models.CharField(max_length=200)
    sub_name = models.CharField(max_length=400, null=True, blank=True)
    icon_url = models.CharField(max_length=400, null=True, blank=True)
    price = models.DecimalField(max_digits=10, decimal_places=0)
    discount_price = models.DecimalField(max_digits=10, decimal_places=0, null=True, blank=True)
    summary = models.TextField(null=True, blank=True)
    content = models.TextField(null=True, blank=True)
    # 关键：设为外键，并指定使用同名列
    status = models.ForeignKey(
        McServerStatus,
        on_delete=models.SET_NULL,
        null=True,
        blank=True,
        db_column="status",
    )
    created_time = models.DateTimeField(auto_now_add=True)
    updated_time = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'mc_service'
        verbose_name = '服务'
        verbose_name_plural = '服务'
